<?php

/**
 * Client form base class.
 *
 * @package    form
 * @subpackage client
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseClientForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'mc_no'       => new sfWidgetFormInput(),
      'name'        => new sfWidgetFormInput(),
      'description' => new sfWidgetFormTextarea(),
      'client_type' => new sfWidgetFormChoice(array('choices' => array('Corporate' => 'Corporate', 'Frequent Individual Traveler' => 'Frequent Individual Traveler', 'Employment Agency' => 'Employment Agency', 'Travel Agency-IATA' => 'Travel Agency-IATA', 'Travel Agency-NonIATA' => 'Travel Agency-NonIATA'))),
      'author'      => new sfWidgetFormDoctrineChoice(array('model' => 'sfGuardUser', 'add_empty' => false)),
      'created_at'  => new sfWidgetFormDateTime(),
      'updated_at'  => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => 'Client', 'column' => 'id', 'required' => false)),
      'mc_no'       => new sfValidatorString(array('max_length' => 11)),
      'name'        => new sfValidatorString(array('max_length' => 255)),
      'description' => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'client_type' => new sfValidatorChoice(array('choices' => array('Corporate' => 'Corporate', 'Frequent Individual Traveler' => 'Frequent Individual Traveler', 'Employment Agency' => 'Employment Agency', 'Travel Agency-IATA' => 'Travel Agency-IATA', 'Travel Agency-NonIATA' => 'Travel Agency-NonIATA'), 'required' => false)),
      'author'      => new sfValidatorDoctrineChoice(array('model' => 'sfGuardUser')),
      'created_at'  => new sfValidatorDateTime(array('required' => false)),
      'updated_at'  => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Client', 'column' => array('mc_no')))
    );

    $this->widgetSchema->setNameFormat('client[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Client';
  }

}
